package com.chookss.video;

import android.app.Activity;
import android.util.Log;

import com.aliyun.apsara.alivclittlevideo.net.NetWatchdog;
import com.aliyun.svideo.common.utils.ToastUtils;
import com.chookss.R;

import java.lang.ref.WeakReference;

/**
 * Company:
 * Project:
 * Author: liuhaoge
 * Date: 2021/1/20 16:34
 * Note:
 */
public class MyNetConnectedListener implements NetWatchdog.NetConnectedListener {
    private WeakReference<Activity> weakReference;

    public MyNetConnectedListener(Activity activity) {
        weakReference = new WeakReference<>(activity);
    }

    @Override
    public void onReNetConnected(boolean isReconnect) {
        if (isReconnect) {
            //网络重连
            Log.e("Test", "onReNetConnected......");
        }
    }

    @Override
    public void onNetUnConnected() {
        Activity activity = weakReference.get();
        if(activity != null){
            ToastUtils.show(activity, "网络不给力，请检查网络");
        }
        //网络断开
        Log.e("Test", "onNetUnConnected......");
    }
}
